package hsh.kernel;

import java.util.Hashtable;
import java.util.List;
import java.util.Queue;

import hsh.gui.LASh;
import hsh.kernel.managers.CommandManager;
import hsh.kernel.managers.DeviceManager;
import hsh.kernel.managers.FileSystemManager;
import hsh.kernel.managers.PrimayMemoryManager;
import hsh.kernel.managers.Scheduler;
import hsh.machine.components.Home;
import hsh.command.HSHCommand;;

public class HSHOSKernel {

	//represent the hardware 
	private Home home;

	//the shell
	private LASh shell;
	
	
	//the status tables
	private Hashtable<Integer,ProcessData> processStatusTable;
	private Hashtable<Integer,DeviceData> deviceStatusTable;
	private Hashtable<Integer,MemoryData> memoryStatusTable;
	
	//commands sent by interface
	private Queue<HSHCommand> commands;
	
	
	//the managers
	private CommandManager commandManager;
	private DeviceManager deviceManager;
	private PrimayMemoryManager primayMemoryManager;
	private Scheduler scheduler;
	private FileSystemManager fileSystemManager;

	
	//interface calls
	public void executeCommand(HSHCommand command){
			commands.add(command);
	}

	private void KernelLoop(){
		managerCommands();
		executeProcess();
	}

	private void executeProcess() {
		
		
		//home.getProcessor().execute(pc, timeInInstructions);
		//checar como o processo terminou?
	}

	private void managerCommands() {
		HSHCommand command = commands.remove();
		//checar fila vazia
		
		if(command.getTask().equals("EXECUTE")){
			String programName = command.getProgramName();
			
			//buscar do hd -> chamar fileSystemManager
			//colocar na memoria principal -> primayMemoryManager
			//criar um novo processo -> scheduler
			//atualizar as tabelas de status
		}
	}
		
}
